package state;

/**
 * Remarks:
 * Class name :Daemon
 * Date :2023/2/14 22:17
 * Author:杨俊源
 */
public class Daemon {
    public static void main(String[] args) {
        God god = new God();
        You you = new You();

        Thread thread = new Thread(god);
        thread.setDaemon(true);//模式是用户线程（false），true为守护线程

        thread.start();

        new Thread(you).start();//用户线程启动
    }
}


class God implements Runnable{
    @Override
    public void run() {
        while (true){
            System.out.println("上帝保护着你");
        }
    }
}
class You implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 36500; i++) {
            System.out.println("活着");
        }
        System.out.println(" died ....");
    }
}
